package com.ruoyi.system.service.impl;
import com.ruoyi.system.domain.Difficult;
import com.ruoyi.system.mapper.DifficultMapper;
import com.ruoyi.system.service.DifficultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: zhang
 * @Date: 2023/02/19/10:17
 * @Description:
 */

@Service
public class DifficultServiceImpl implements DifficultService {
    @Autowired
    private DifficultMapper mapper;

    @Override
    public boolean saveOrUpdate(Difficult difficult) {
        if(difficult.getId()==null){
            return mapper.insertDifficult(difficult)==1?true:false;
        }
        return mapper.updateDifficult(difficult)==1?true:false;
    }

    @Override
    public boolean removeById(Integer id) {
        return mapper.deleteById(id)==1;
    }

    @Override
    public boolean removeByIds(Integer[] ids) {
        int flag =0;
        for(int i=0;i<ids.length;i++){
            flag+=mapper.deleteById(ids[i]);
        }
        return flag==ids.length;
    }

    @Override
    public Difficult queryById(Integer id) {
        return mapper.selectById(id);
    }

    @Override
    public List<Difficult> queryDifficults(Difficult difficult) {
        return mapper.select(difficult);
    }
}
